/**
 * 我的 页面  数据请求
 * Created by lenovo on 2017/6/23.
 */
// import uris from './uris'
import responseHandler from './response-handler'
// import apiHost from 'settings/api-host'
import Vue from 'vue'

import headerFavicon from 'assets/favicon.png'


import iconReturned from 'assets/icon_returned.png';
import iconPay from 'assets/icon_pay.png';
import iconNotpay from 'assets/icon_notpay.png';
import iconDiscuss from 'assets/icon_discuss.png';

import AccountBaoxian from 'assets/Account_baoxian.png';
import AccountBaoyang from 'assets/Account_baoyang.png';
import AccountNianjian from 'assets/Account_nianjian.png';

import iconTrolley from 'assets/icon_trolley.png';
import iconFav from 'assets/icon_fav.png';
import iconChangegoods from 'assets/icon_changegoods.png';
import iconSavemoney from 'assets/icon_savemoney.png';


import iconCarinformation from 'assets/icon_carinformation.png'
import iconPhonecard from 'assets/icon_phonecard.png'
import iconQrcode from 'assets/icon_qrcode.png'
export default {
  getMyPagesTopInfo(params, success, fail){
    function makeData (originalData) {
      //判断是否有头像
      console.log(originalData)
      if (!originalData.headerUrl) {
        //   没有头像的情况
        console.log(apiHost.dynamicHost.get())
        return {
          userNickname: originalData.userNickname,
          motCarId: originalData.motCarId,
          headerUrl: headerFavicon,
          qrCode: Vue.prototype.$.host + originalData.qrCode,
          signInState: parseInt(originalData.signInState, 10),
          shopContinueSignDays: originalData.shopContinueSignDays || 0,
          uri: 'router_persionInfo',
          isVue: false,
          //签到人的位置
          memberPosition: originalData.location,
          maintain: originalData.maintain || null,
          insurance: originalData.insurance || null,
          annualInspect: originalData.annualInspect || null,
          rank: originalData.rank
        }
      } else {
        // 有头像
        return {
          userNickname: originalData.userNickname,
          motCarId: originalData.motCarId,
          headerUrl: Vue.prototype.$.host + originalData.headerUrl,
          qrCode: Vue.prototype.$.host + originalData.qrCode,
          signInState: parseInt(originalData.signInState, 10),
          shopContinueSignDays: originalData.shopContinueSignDays || 0,
          uri: 'router_persionInfo',
          isVue: false,
          memberPosition: originalData.location,
          maintain: originalData.maintain || null,
          insurance: originalData.insurance || null,
          annualInspect: originalData.annualInspect || null,
          rank: originalData.rank
        }
      }
    }

    // this.$http.get(uris.myPages.getTopInfo(params), responseHandler.success(success, fail, makeData), responseHandler.error(fail))
    params['methodName'] = 'QueryUserInfo'
    // this.$http.get(uris.myPages.getTopInfo(params))
    Vue.prototype.$.get(params)
      .then(responseHandler.success(success, fail, makeData), responseHandler.error(fail))
  },
  //我的页面签到提交
  postMypagesSignInState(params, success, fail){
    function makeData (originlData) {
      return {}
    }

    // this.$http.get(uris.myPages.postSignInState(params))
    params['methodName'] = 'SignForPlatform'
    Vue.prototype.$.get(params)
      .then(responseHandler.success(success, fail, makeData), responseHandler.error(fail))
  },
//  获取订单的数量
  getIndentNumber(params, success, fail){
    function makeData (originlData) {
      return {
        unPay: originlData.unPay,
        unReceive: originlData.unReceive || 0,
        unComment: originlData.unComment,
        refund: originlData.refund
      }
    }
    params['methodName'] = 'ManageOrder'
    Vue.prototype.$.get(params)
    // this.$http.get(uris.myPages.getIndentNm(params))
      .then(responseHandler.success(success, fail, makeData), responseHandler.error(fail))
  },
  myList: [
    // {
    //   title: '车辆信息',
    //   uri: 'router_carInfo',
    //   isVue: false
    // },
    {
      title: '用车账单',
      uri: '#car_bill',
      isVue: true
    },
    {
      title: '我的动态',
      uri: 'router_personalSpace',
      isVue: false
    },
    {
      title: '设置',
      uri: 'router_setting',
      isVue: false
    }
  ],
  myRemind: [
    {
      remindText1: '下次保养',
      remindText2: '保养提醒',
      remindNum: '0',
      remindIcon: AccountBaoyang,
      uri: 'router_carDetailInfo'
    },
    {
      remindText1: '保险到期',
      remindText2: '保险提醒',
      remindNum: '0',
      remindIcon: AccountBaoxian,
      uri: 'router_carDetailInfo'
    },
    {
      remindText1: '年检到期',
      remindText2: '年检提醒',
      remindNum: '0',
      remindIcon: AccountNianjian,
      uri: 'router_carMOTInfo'
    }
  ],
  myIndentMember: [
    {
      title: {
        name: '我的订单',
        uri: '#orderlist/0',
        isVue: true,
        isShow:true
      },
      content: [
        {
          indentText: '待付款',
          indentNum: '0',
          indentIcon: iconNotpay,
          uri: '#orderlist/1',
          isVue: true
        },
        {
          indentText: '待使用',
          indentNum: '0',
          indentIcon: iconPay,
          uri: '#orderlist/2',
          isVue: true
        },
        {
          indentText: '待评价',
          indentNum: '0',
          indentIcon: iconDiscuss,
          uri: '#orderlist/3',
          isVue: true
        },
        {
          indentText: '退货/退款',
          indentNum: '0',
          indentIcon: iconReturned,
          uri: '#orderlist/4',
          isVue: true
        }
      ]
    },
    {
      title: {
        name: '会员中心',
        uri: '#orderManage',
        isVue: true,
        isShow:true
      },
      content: [
        {
          indentText: '购物车',
          indentNum: '0',
          indentIcon: iconTrolley,
          uri: '#asc_shoppingCart',
          isVue: true
        },
        {
          indentText: '收藏夹',
          indentNum: '0',
          indentIcon: iconFav,
          uri: '#collection',
          isVue: true
        },
        {
          indentText: '卡券',
          indentNum: '0',
          indentIcon: iconSavemoney,
          uri: '#cb_card',
          isVue: true
        },
        {
          indentText: 'V豆商城',
          indentNum: '0',
          indentIcon: iconChangegoods,
          uri: '#sg_goodsList?isVBean=true',
          isVue: true
        }
      ]
    },
    {
      title: {
        name: '车辆中心',
        uri: '',
        isShow:false
      },
      content: [
        {
          indentText: '车辆信息',
          indentNum: '0',
          indentIcon: iconCarinformation,
          uri: 'router_carInfo',
          isVue: false,
          idWebvive:true
        },
        {
          indentText: '通讯卡充值',
          indentNum: '0',
          indentIcon: iconPhonecard,
          uri: '#communication_card',
          isVue: true
        },
        {
          indentText: '挪车码',
          indentNum: '0',
          indentIcon: iconQrcode,
          uri: 'router_carQrcode',
          isVue: false,
          idWebvive:true
        }
      ]
    }

  ]
}
